<template>
    <div>
      <input type="text" @keyup="handleKeyup($event)">
      <span v-if="count>0">您按了回车键{{ count }}次</span><br>
      <input type="text" @keyup.enter="handleKeyup1()">
      <span v-if="number>0">您按了回车键{{ number }}次</span>
    </div>
  </template>
  
  <script>
  import { reactive, toRefs } from 'vue'
  
  export default {
    setup () {
      const state = reactive({
        count: 0,
        number:0,
      })
      const handleKeyup=(e)=>{
        if(e.keyCode===13) state.count++
      }
      const handleKeyup1=()=>{
        state.number++
      }
      return {
        ...toRefs(state),
        handleKeyup,
        handleKeyup1
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  
  </style>